package com.jwcao.common.cast.context;

import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;

/**
 * name: KeyFactory description: TODO
 *
 * @author caojingwei date: 2023/3/24 10:34
 */
public class KeyFactory {

    private final static String FORMAT = "%s:%s:%s";

    private final static String FORMAT_WITHOUT_ID = "%s:%s";

    public static String get(Class sourceClass, Class targetClass, String id) {
        String aName = sourceClass.getName();
        String bName = targetClass.getName();

        return String.format(FORMAT, aName, bName, id);
    }

    public static String getWithoutId(Class sourceClass, Class targetClass) {
        String aName = sourceClass.getName();
        String bName = targetClass.getName();

        return String.format(FORMAT_WITHOUT_ID, aName, bName);
    }

    public static boolean match(String key, String matchStr) {
        return StringUtils.contains(key, matchStr);
    }
}
